package cn.laixueit;

import java.util.Scanner;

public class Demo4 {
    public static void main(String[] args) {
        /*程序是严谨的*/
        int[] xuehao = new int[999];
        String[] xingming = new String[999];
        Scanner scanner = new Scanner(System.in);
        int i = 0;
        while (true) {
            System.out.println("1 输入学号，输出学号对应的学生姓名");
            System.out.println("2 继续录入学生信息");
            int option = scanner.nextInt();
            switch (option){
                case 1:
                    System.out.println("请输入你要查询学生的学号：");
                    int xh = scanner.nextInt();// 1
                    System.out.println(xh);
                    String name = xingming[xh-1];
                    if(name == null){
                        System.out.println("无法查询到该学生信息,请确保您输入的学号是正确的！");
                        break;
                    }
                    System.out.println("该学生信息如下:");
                    System.out.println(xingming[xh-1]);
                    break;
                case 2:
                    System.out.println("请输入学生的学号:");
                    xuehao[i] = scanner.nextInt();//i = 0 ,= 1
                    System.out.println("请输入学生的姓名:");
                    xingming[i] = scanner.next();
                    i++;
                    break;
                default:
                    System.out.println("录入错误,请重新选择");
            }
        }
    }
}